﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：V_OrderItem.cs
//
//
//文件功能描述：对应数据库中V_OrderItem视图的数据操作接口以SQL2000的操作来实现
//
//
//创建标识：2007.11.15 王林进
//创建描述：机器生成
//
//
//------------------------------------*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using JXMSTC.SmartBusiness.DAL.IDAL;
using JXMSTC.SmartBusiness.DAL.DbHelperSQL;//数据访问抽象基类
namespace JXMSTC.SmartBusiness.DAL.SQL2000DAL
{
    /// <summary>
    /// 数据访问类V_OrderInfo 。
    /// </summary>
    public class V_OrderInfo : IV_OrderInfo
    {
        public V_OrderInfo()
        { }
        #region  成员方法

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JXMSTC.SmartBusiness.Common.Model.V_OrderInfo GetModel(string OrderInfoID)
        {
            //SqlParameter[] parameters = {
            //        new SqlParameter("@OrderInfoID", SqlDbType.Int,4)
            //    };
            SqlParameter[] parameters = {new SqlParameter("@OrderInfoID", SqlDbType.NVarChar)};
            parameters[0].Value = OrderInfoID;
            JXMSTC.SmartBusiness.Common.Model.V_OrderInfo model = new JXMSTC.SmartBusiness.Common.Model.V_OrderInfo();

            DataSet ds = DbHelperSQL.DbHelperSQL.RunProcedure("UP_V_OrderInfo_GetModel", parameters, "ds");
            model.OrderInfoID = OrderInfoID;
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.OrderInfoID = ds.Tables[0].Rows[0]["OrderInfoID"].ToString();
                model.CustomerID = ds.Tables[0].Rows[0]["CustomerID"].ToString();
                model.ShipToFirstName = ds.Tables[0].Rows[0]["ShipToFirstName"].ToString();
                model.ShipToLastName = ds.Tables[0].Rows[0]["ShipToLastName"].ToString();
                model.ShipAddress = ds.Tables[0].Rows[0]["ShipAddress"].ToString();
                model.ShipCity = ds.Tables[0].Rows[0]["ShipCity"].ToString();
                model.ShipProvince = ds.Tables[0].Rows[0]["ShipProvince"].ToString();
                model.ShipZip = ds.Tables[0].Rows[0]["ShipZip"].ToString();
                model.ShipMethod = ds.Tables[0].Rows[0]["ShipMethod"].ToString();
                model.BillMethod = ds.Tables[0].Rows[0]["BillMethod"].ToString();
                if (ds.Tables[0].Rows[0]["TotalPrice"].ToString() != "")
                {
                    model.TotalPrice = decimal.Parse(ds.Tables[0].Rows[0]["TotalPrice"].ToString());
                }
                model.BillToFirstName = ds.Tables[0].Rows[0]["BillToFirstName"].ToString();
                model.BillToLastName = ds.Tables[0].Rows[0]["BillToLastName"].ToString();
                model.Phone = ds.Tables[0].Rows[0]["Phone"].ToString();
                if (ds.Tables[0].Rows[0]["CreationTime"].ToString() != "")
                {

                    model.CreationTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreationTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PaymentStatus"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["PaymentStatus"].ToString() == "1") || (ds.Tables[0].Rows[0]["PaymentStatus"].ToString().ToLower() == "true"))
                    {
                        model.PaymentStatus = true;
                    }
                    else
                    {
                        model.PaymentStatus = false;
                    }
                }

                if (ds.Tables[0].Rows[0]["ConsignmentStatus"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["ConsignmentStatus"].ToString() == "1") || (ds.Tables[0].Rows[0]["ConsignmentStatus"].ToString().ToLower() == "true"))
                    {
                        model.ConsignmentStatus = true;
                    }
                    else
                    {
                        model.ConsignmentStatus = false;
                    }
                }

                if (ds.Tables[0].Rows[0]["ArchivingStatus"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["ArchivingStatus"].ToString() == "1") || (ds.Tables[0].Rows[0]["ArchivingStatus"].ToString().ToLower() == "true"))
                    {
                        model.ArchivingStatus = true;
                    }
                    else
                    {
                        model.ArchivingStatus = false;
                    }
                }

                if (ds.Tables[0].Rows[0]["SaleesmanID"].ToString() != "")
                {
                    model.SaleesmanID = int.Parse(ds.Tables[0].Rows[0]["SaleesmanID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ArchivingTime"].ToString() != "")
                {

                    model.ArchivingTime = DateTime.Parse(ds.Tables[0].Rows[0]["ArchivingTime"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取数据列表
        /// </summary>
        public DataSet GetList()
        {
            SqlParameter[] parameters = {  };
            return DbHelperSQL.DbHelperSQL.RunProcedure("UP_V_OrderInfo_GetList", parameters, "ds");
        }

        /// <summary>
        /// 获取数据列表
        /// </summary>
        public DataSet GetList(string  strWhere)
        {
            SqlParameter[] parameters = {new SqlParameter ("@strWhere",SqlDbType.VarChar ,200)};
            parameters[0].Value = strWhere;
            return DbHelperSQL.DbHelperSQL.RunProcedure("UP_V_OrderInfo_GetList", parameters, "ds");
        }

        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="PageSize">页大小</param>
        /// <param name="PageIndex">所获页号</param>
        /// <param name="strWhere">查询条件</param>
        /// <returns>分页dataset</returns>
        /// <remarks>
        /// 修改标识：2007.11.28 殷悦 开放
        /// </remarks>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "V_OrderInfo";
            parameters[1].Value = "OrderInfoID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 1;
            parameters[6].Value = strWhere;
            return DbHelperSQL.DbHelperSQL.RunProcedure("UP_GetRecordByPage", parameters, "ds");
        }

        ///// <summary>
        ///// 分页获取数据总行数
        ///// </summary>
        public DataSet GetListRows(string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "V_OrderInfo";
            parameters[1].Value = "OrderInfoID";
            parameters[2].Value = 10;
            parameters[3].Value = 1;
            parameters[4].Value = 1;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;
            return DbHelperSQL.DbHelperSQL.RunProcedure("UP_GetRecordByPage", parameters, "ds");
        }
        #endregion  成员方法
    }
}

